'use strict';
/* jshint mocha: true */

var path = require('path');
var expect = require('chai').expect;
var Injector = require('injector');

var projectPath = path.resolve(__dirname, '..');
var includePaths = [projectPath + '/lib', projectPath + '/example'];

describe('test/test_static', function () {
    it('#AppError.create', function () {
        function test(AppError) {
            expect(function () {
                var appError = AppError.create();
                expect(appError).to.be.a('object');
            }).to.throw(Error);
            expect(function () {
                var appError = AppError.create('UNKNOWN');
                expect(appError).to.be.a('object');
            }).to.not.throw(Error);
            expect(function () {
                var appError = AppError.create('UNKNOWN1');
                expect(appError).to.be.a('object');
            }).to.throw('There is not a error named');
        }
        var injector = new Injector(includePaths, {});
        var moduleDefinition = Injector.define([
            'component/app_error'
        ], test);
        injector.inject(moduleDefinition);
    });
    it('#AppError.createWithCode', function () {
        function test(AppError) {
            expect(function () {
                var appError = AppError.createWithCode(1);
                expect(appError).to.be.a('object');
                expect(appError.getCode()).to.equal(1);
            }).to.not.throw(Error);
            expect(function () {
                var appError = AppError.createWithCode(2);
                expect(appError).to.be.a('object');
                expect(appError.getCode()).to.equal('2');
                expect(appError.getCode()).to.not.equal(2);
            }).to.not.throw(Error);
            expect(function () {
                var appError = AppError.createWithCode('2');
                expect(appError).to.be.a('object');
                expect(appError.getCode()).to.equal('2');
                expect(appError.getCode()).to.not.equal(2);
            }).to.not.throw(Error);
            expect(function () {
                var appError = AppError.createWithCode('a2');
                expect(appError).to.be.a('object');
                expect(appError.getCode()).to.equal('a2');
            }).to.not.throw(Error);
            expect(function () {
                var appError = AppError.createWithCode('3');
                expect(appError).to.be.a('object');
            }).to.throw('There is not a error coded');
        }
        var injector = new Injector(includePaths, {});
        var moduleDefinition = Injector.define([
            'component/app_error'
        ], test);
        injector.inject(moduleDefinition);
    });
    it('#AppError.hasInstance', function () {
        function test(AppError) {
            expect(AppError.hasInstance(new AppError(1))).to.equal(true);
            expect(AppError.hasInstance()).to.equal(false);
            expect(AppError.hasInstance({})).to.equal(false);
            expect(AppError.hasInstance(1)).to.equal(false);
            expect(AppError.hasInstance('')).to.equal(false);
        }
        var injector = new Injector(includePaths, {});
        var moduleDefinition = Injector.define([
            'component/app_error'
        ], test);
        injector.inject(moduleDefinition);
    });
    it('#AppError.ERROR_NAME', function () {
        function test(AppError) {
            var appError = AppError.UNKNOWN;
            expect(appError).to.be.an('object');
            expect(appError.getCode()).to.equal(1);
        }
        var injector = new Injector(includePaths, {});
        var moduleDefinition = Injector.define([
            'component/app_error'
        ], test);
        injector.inject(moduleDefinition);
    });
});